import type { MenuApi } from '#/api/types';

import { Http as http } from '#/api/http';

/**
 * 获取菜单列表
 */
export async function getAllMenuListApi() {
  return http.get<MenuApi.MenuTree[]>('/system/menu/tree');
}

/**
 * 创建菜单
 */
export async function createMenuApi(data: MenuApi.CreateMenuParam) {
  return http.post('/system/menu/add', data);
}

/**
 * 更新菜单
 */
export async function updateMenuApi(id: any, data: MenuApi.MenuTree) {
  return http.post(`/system/menu/update/${id}`, data);
}

/**
 * 获取菜单详情
 */
export async function getMenuDetailApi(id: number | string) {
  return http.get<MenuApi.MenuTree>(`/system/menu/detail/${id}`);
}

/**
 * 删除菜单
 */
export async function deleteMenuApi(param: {
  deepDelete: number;
  id: number | string;
}) {
  return http.post(`/system/menu/delete`, param);
}

/**
 * 批量删除菜单
 */
export async function batchDeleteMenuApi(ids: (number | string)[]) {
  return http.post('/system/menu/delete-batch', { ids: { ids } });
}
